package com.qf.pojo;

import javax.security.auth.login.LoginContext;
import java.util.List;

/**
 * @Author AzureSky_X
 * @Date 2021/1/14 20:39
 * @Version 1.0
 * 分页基类
 */
public class PageBean <T>{
    //当前页
    private Integer pageNo;

    //页大小 每页几条记录
    public final Integer pageSize=5;

    //当前页的内容
    private List<T>  list;

    //总条数
    private Long totalCount;

    //总页数 计算得到
    private Long totalPages;

    public Long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public Long getTotalPages() {
        return totalPages;
    }

    public void setTotalPages() {
        //总页数=总条数 % 页大小，若有余数，总页数+1；若无余数，总页数不变
        this.totalPages = this.totalCount % this.pageSize==0?this.totalCount/this.pageSize:this.totalCount/this.pageSize+1;
        //this.totalPages = (long)(Math.ceil((double)this.totalCount / this.pageSize));
    }
}
